{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 商城管理
    <span class="c-gray en">&gt;</span> 商品列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="/shop/goods" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form  method="get" action="">

    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
          <span class="l">
            <a href="javascript:;" onclick="layopen('新增配置','{:url('goods_edit')}',800,600)" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i>新增商品</a>
        </span>

    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="14">商品列表</th>
        </tr>
        <tr class="text-c">
            <th width="100">商品名称</th>
            <th width="100">商品图片</th>
            <th width="100">商品价格</th>
<!--            <th width="50">商品介绍</th>-->
            <th width="50">上架时间</th>
            <th width="50">更新时间</th>
            <th width="50">状态</th>
            <th width="120">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
        <tr class="text-c">
            <td>{$v.name}</td>
            <td><img src="{$v.img}" style="width: 60px;height: 60px"></td>
            <td>{$v.price}</td>
<!--            <td>{$v.content}</td>-->
            <td>{$v.create_time}</td>
            <td>{$v.update_time}</td>
            <td> {if $v.status == 1}
                <a href="javascript:;" class="label label-success radius" onclick="setshow(0,{$v.id});">上架中</a>
                {else /}
                <a href="javascript:;" class="label label-danger radius" onclick="setshow(1,{$v.id});">已下架</a>
                {/if}
            </td>
            <td>
                <a class="btn btn-default radius" title="编辑" href="javascript:;" onclick="layopen('编辑','{:url('goods_edit',['id'=>$v.id])}',800,700)"><i class="Hui-iconfont">&#xe6df;</i></a>
                <a class="btn btn-default radius good_del" title="删除" href="javascript:;" onclick="setshow(2,{$v.id})"><i class="Hui-iconfont">&#xe609;</i></a>
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
</div>

{include file="public/footer" /}
<script type="text/javascript">


    /*商品上下架*/
    function setshow(sta,id) {
        switch (sta) {
            case 0:
                var tip = '确认要下架吗？';
                break;
            case 1:
                var tip = '确认要上架吗？';
                break;
            case 2:
                var tip = '确认要删除吗？';
        }

        layer.confirm(tip,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('setstatus')}",
                data:{'status':sta,'id':id},
                dataType: 'json',
                success: function(data){
                    if(data.status == 1){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.reload();
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });

    }
</script>
